cap log close
log using "Z:\Angrist Work\Web Papers\Angrist_1993\Angrist1993_Table5.log", replace

****************************************
* PROGRAM: Angrist1993_Table5
* PROGRAMMER: Simone Schaner
* PURPOSE: Recreates Table 5 of Angrist
*	(1993)
* DATE CREATED: 8/6/07
* NOTES: 
****************************************

clear
set mem 50m
set more off

cd "Z:\Angrist Work\Web Papers\Angrist_1993"

use soviii_ang93b

* MAKE EXTRACT -- THIS PART OF CODE IS THE SAME AS THE CODE FOR TABLE 1

g byte vietnam= q4c8==1
g byte earlyavf= q4c9==1

g byte age= (agerec==2)*22 + (agerec==3)*27 + (agerec==4)*32 + ///
	(agerec==5)*37 + (agerec==6)*42 + (agerec==7)*47 + ///
	(agerec==8)*52 + (agerec==9)*57 + (agerec==10)*62 + ///
	(agerec==11)*67
replace age=. if agerec<2 | agerec>11	

g yrsrv= (q13c==2)*1.75 + (q13c==3)*4 + (q13c==4)*8 + (q13c==5)*13
	replace yrsrv=. if q13c<2 | q13c>5

g byte female= sex==2

g entgrade= (q15a==1)*0 + (q15a==2)*8 + (q15a==3)*9 + ///
	(q15a==4)*10 + (q15a==5)*11 + (q15a==6)*12 + ///
	(q15a==7)*13 + (q15a==8)*13 + (q15a==9)*14 + ///
	(q15a==10)*15 + (q15a==11)*16 + (q15a==12)*17 + ///
	(q15a==13)*18 + (q15a>13)*-99
		replace entgrade=20 if q15b==4
		replace entgrade=0 if entgrade<0

g curgrade= (q15c==1)*0 + (q15c==2)*8 + (q15c==3)*9 + ///
	(q15c==4)*10 + (q15c==5)*11 + (q15c==6)*12 + ///
	(q15c==7)*13 + (q15c==8)*13 + (q15c==9)*14 + ///
	(q15c==10)*15 + (q15c==11)*16 + (q15c==12)*17 + ///
	(q15c==13)*18 + (q15c>13)*-99
		replace curgrade=20 if q15d==4
		replace curgrade=0 if curgrade<0

g eddif= curgrade-entgrade

g byte drafted= q10==1
g byte officer= q12==1 | q12==2
g size=cenplsz
g byte curmar= q14a==1
g byte entmar= q14b==1
g byte entvoc= q15a==7
g byte curvoc= q15c==7

g byte health= q22c==1
g byte nonwhite= racerec>1
g byte hispanic= q3b==1
g byte knowgi= q31_3==1
g byte vcomp= q35f==1
g vcompamt= q35g*(q35g<12)
g disper= q35j*(q35j<12)
g byte usevoc= q38a==1
g byte newed= q39a==1
g byte anyaid= q39d==1
g byte anyfed= q39e1==1 | q39e2==1 | q39e3==1

g byte gibill= q39e5==1
g byte veap= q39e6==1
g byte otherva= q39e7==1 | q39e8==1
g byte anyva= gibill | veap | otherva

g byte inelig= q39f==1

g spoused= (q46a==1)*0 + (q46a==2)*8 + (q46a==3)*9 + ///
	(q46a==4)*10 + (q46a==5)*11 + (q46a==6)*12 + ///
	(q46a==7)*13 + (q46a==8)*13 + (q46a==9)*14 + ///
	(q46a==10)*15 + (q46a==11)*16 + (q46a==12)*17 + ///
	(q46a==13)*18 + (q46a>13)*-99
		replace spoused=20 if q46b5==1
		replace spoused=0 if spoused<0

g byte spsvoc= q46a==7

g byte spswork= q46c==1 | q46c==1
g byte fulltime= q47a==1
g byte parttime= q47a==2
g byte unem= q47a==3
g byte outlf= q47a==3 | q47a>5

g earn86= q59a
	g lnearn= ln(earn86)
g self86= q59b
	g lnself= ln(self86)
g spsern86= q64a
g spself86= q64b

g numdep= q68a
g byte depchild= q70a==1

g mardif= curmar-entmar

g byte hs= q39b1
g byte coll_grad= q39b2==1 | q39b3==1
g byte corresp= q39b7==1
g byte voc_tech= q39b4==1
g byte ojt_appren= q39b5==1 | q39b6==1
g byte oth_train = q39b8==1 | q39b9==1 | q39b10==1 | q39b11==1
g byte nviet= vietnam==0
g byte white= nonwhite==0
* SELECTION CRITERIA

keep if entgrade>8 & entgrade<=16
keep if eddif>=0 & (vietnam==1 | earlyavf==1)
keep if age>=25 & age<=52
keep if yrsrv~=.

keep vetwgt age agerec pser_02 pser_07 pser_08 vietnam-white

g lths_ent_nv= entgrade<12 & vietnam==0
g lths_ent_v= entgrade<12 & vietnam==1
g hsup_ent_nv= entgrade>11 & vietnam==0
g hsup_ent_v= entgrade>11 & vietnam==1
g hsup= entgrade>=12
g hsup_viet= hsup*vietnam

* GRADE INCREMENT
	reg eddif vietnam hsup hsup_viet
			* VIETNAM x LTHS
				di _b[vietnam]+_b[_cons]
			* VIETNAM x HSUP
				di _b[vietnam]+_b[_cons]+_b[hsup]+_b[hsup_viet]
			* DIFF BETWEEN HS FOR VIETNAM
				di _b[hsup]+_b[hsup_viet]
				di (_se[hsup_viet]^2-_se[hsup]^2)^.5
			* DIFF BETWEEN VIETNAM FOR HSUP
				di _b[vietnam]+_b[hsup_viet]
				di (_se[hsup_viet]^2-_se[vietnam]^2)^.5
				
	* USE OF VA BENEFITS
	reg anyva vietnam hsup hsup_viet
			* VIETNAM x LTHS
				di _b[vietnam]+_b[_cons]
			* VIETNAM x HSUP
				di _b[vietnam]+_b[_cons]+_b[hsup]+_b[hsup_viet]
			* DIFF BETWEEN HS FOR VIETNAM
				di _b[hsup]+_b[hsup_viet]
				di (_se[hsup_viet]^2-_se[hsup]^2)^.5
			* DIFF BETWEEN VIETNAM FOR HSUP
				di _b[vietnam]+_b[hsup_viet]
				di (_se[hsup_viet]^2-_se[vietnam]^2)^.5
log close
	